package com.equipment.training.web.activemq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.TextMessage;

/**
 * 消费者
 *
 * @author Administrator
 */
@Component
public class Consumer {


	private final Logger logger = LoggerFactory.getLogger(Consumer.class);



	@Async
	@JmsListener(destination = "peixun.queue")
	public void receiveQueue(final TextMessage message) throws JMSException {
		try {
			String json = null;
			json = message.getText();
			System.out.println(json);
			//确认接收，并成功处理了消息
			message.acknowledge();
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}

}